package com.xoms.admin.controller.springmvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.*;
import com.xoms.admin.controller.res.*;
import com.xoms.admin.controller.res.bean.*;
import com.xoms.admin.controller.springmvc.req.*;

/**
 * 影厅相关接口
 **/
@Controller
@RequestMapping(value = "/room", produces = "application/json")
public class SRoomController {
	@Autowired
	com.xoms.admin.controller.RoomController roomController;

	/**
	 * 获取影厅类型维度列表
	 **/
	@RequestMapping("/v1/getDimensions")
	@ResponseBody
	public ListResult<RRoomDimensionBean> getDimensions(HttpServletRequest request, HttpServletResponse response) {

		return roomController.getDimensions(request, response);
	}

	/**
	 * 获取影厅类型维度详细列表
	 **/
	@RequestMapping("/v1/getDimensionDetails")
	@ResponseBody
	public ListResult<RRoomDimensionDetailBean> getDimensionDetails(@Validated GetRoomDimensionDetailsParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RRoomDimensionDetailBean> res = new ListResult<RRoomDimensionDetailBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.getDimensionDetails(param, request, response);
	}

	/**
	 * 获取影厅类型维度详细列表
	 **/
	@RequestMapping("/v1/getDimensionAllDetail")
	@ResponseBody
	public ListResult<RRoomDimensionDetailBean> getDimensionAllDetail(HttpServletRequest request, HttpServletResponse response) {

		return roomController.getDimensionAllDetail(request, response);
	}

	/**
	 * 增加/修改维度详情
	 **/
	@RequestMapping("/v1/editDimensionDetail")
	@ResponseBody
	public ObjectResult<RRoomDimensionDetailBean> editDimensionDetail(@Validated EditRoomDimensionDetailParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ObjectResult<RRoomDimensionDetailBean> res = new ObjectResult<RRoomDimensionDetailBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.editDimensionDetail(param, request, response);
	}

	/**
	 * 删除维度详情内容
	 **/
	@RequestMapping("/v1/delDimensionDetail")
	@ResponseBody
	public BaseResult delDimensionDetail(@Validated DelByIdParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		BaseResult res = new BaseResult();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.delDimensionDetail(param, request, response);
	}

	/**
	 * 获取影厅类型组合下拉列表
	 **/
	@RequestMapping("/v1/getDimensionScaleDownList")
	@ResponseBody
	public ListResult<RRoomDimensionScaleBean> getDimensionScaleDownList(@Validated GetRoomDimensionScaleParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RRoomDimensionScaleBean> res = new ListResult<RRoomDimensionScaleBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.getDimensionScaleDownList(param, request, response);
	}

	/**
	 * 获取影厅类型组合列表
	 **/
	@RequestMapping("/v1/getDimensionScaleList")
	@ResponseBody
	public ListResult<RRoomDimensionScaleListBean> getDimensionScaleList(HttpServletRequest request, HttpServletResponse response) {

		return roomController.getDimensionScaleList(request, response);
	}

	/**
	 * 增加/修改维度组合
	 **/
	@RequestMapping("/v1/editDimensionScale")
	@ResponseBody
	public ObjectResult<RRoomDimensionScaleBean> editDimensionScale(@Validated EditRoomDimensionScaleParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ObjectResult<RRoomDimensionScaleBean> res = new ObjectResult<RRoomDimensionScaleBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.editDimensionScale(param, request, response);
	}

	/**
	 * 获取影厅列表
	 **/
	@RequestMapping("/v1/getRoomList")
	@ResponseBody
	public ListResult<RRoomBean> getRoomList(@Validated GetRoomListParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RRoomBean> res = new ListResult<RRoomBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.getRoomList(param, request, response);
	}

	/**
	 * 编辑影厅
	 **/
	@RequestMapping("/v1/editRoom")
	@ResponseBody
	public ObjectResult<RRoomBean> editRoom(@Validated EditRoomParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ObjectResult<RRoomBean> res = new ObjectResult<RRoomBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.editRoom(param, request, response);
	}

	/**
	 * 删除影厅
	 **/
	@RequestMapping("/v1/delRoom")
	@ResponseBody
	public BaseResult delRoom(@Validated DelByIdParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		BaseResult res = new BaseResult();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.delRoom(param, request, response);
	}

	/**
	 * 获取时间段列表
	 **/
	@RequestMapping("/v1/getTimeBucketList")
	@ResponseBody
	public ListResult<RTimeBucketBean> getTimeBucketList(HttpServletRequest request, HttpServletResponse response) {

		return roomController.getTimeBucketList(request, response);
	}

	/**
	 * 添加时间段
	 **/
	@RequestMapping("/v1/addTimeBucket")
	@ResponseBody
	public ObjectResult<RTimeBucketBean> addTimeBucket(@Validated AddTimeBucketParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ObjectResult<RTimeBucketBean> res = new ObjectResult<RTimeBucketBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.addTimeBucket(param, request, response);
	}

	/**
	 * 删除时间段
	 **/
	@RequestMapping("/v1/delTimeBucket")
	@ResponseBody
	public BaseResult delTimeBucket(@Validated GetByNameParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		BaseResult res = new BaseResult();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.delTimeBucket(param, request, response);
	}

	/**
	 * 获取指定名字所有时间段
	 **/
	@RequestMapping("/v1/getTimeBucket")
	@ResponseBody
	public ListResult<RTimeBucketBean> getTimeBucket(@Validated GetByNameParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RTimeBucketBean> res = new ListResult<RTimeBucketBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.getTimeBucket(param, request, response);
	}

	/**
	 * 设置组合价格
	 **/
	@RequestMapping("/v1/addDimePrice")
	@ResponseBody
	public BaseResult addDimePrice(@Validated AddDimePriceParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		BaseResult res = new BaseResult();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.addDimePrice(param, request, response);
	}

	/**
	 * 设置影厅价格
	 **/
	@RequestMapping("/v1/addRoomPrice")
	@ResponseBody
	public BaseResult addRoomPrice(@Validated AddRoomPriceParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		BaseResult res = new BaseResult();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.addRoomPrice(param, request, response);
	}

	/**
	 * 查询影厅价格设置列表
	 **/
	@RequestMapping("/v1/getRoomPriceList")
	@ResponseBody
	public ListResult<RRoomPriceBean> getRoomPriceList(@Validated GetRoomPriceListParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RRoomPriceBean> res = new ListResult<RRoomPriceBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.getRoomPriceList(param, request, response);
	}

	/**
	 * 查询某次影厅设置价格
	 **/
	@RequestMapping("/v1/getRoomPriceDetail")
	@ResponseBody
	public ListResult<RRoomPriceBean> getRoomPriceDetail(@Validated GetRoomPriceDetailParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RRoomPriceBean> res = new ListResult<RRoomPriceBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.getRoomPriceDetail(param, request, response);
	}

	/**
	 * 查询当前有效的影厅价格
	 **/
	@RequestMapping("/v1/getRoomCurrPrice")
	@ResponseBody
	public ListResult<RRoomPriceBean> getRoomCurrPrice(@Validated GetByIdParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RRoomPriceBean> res = new ListResult<RRoomPriceBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.getRoomCurrPrice(param, request, response);
	}

	/**
	 * 查询影厅一个月的价格
	 **/
	@RequestMapping("/v1/getRoomMonthPrice")
	@ResponseBody
	public ListResult<RRoomMonthPriceBean> getRoomMonthPrice(@Validated GetRoomMonthPriceParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RRoomMonthPriceBean> res = new ListResult<RRoomMonthPriceBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.getRoomMonthPrice(param, request, response);
	}

	/**
	 * 查询价格设置列表
	 **/
	@RequestMapping("/v1/getDimePriceList")
	@ResponseBody
	public ListResult<RDimePriceBean> getDimePriceList(@Validated GetDimePriceListParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RDimePriceBean> res = new ListResult<RDimePriceBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.getDimePriceList(param, request, response);
	}

	/**
	 * 查询某次设置价格
	 **/
	@RequestMapping("/v1/getDimePriceDetail")
	@ResponseBody
	public ListResult<RDimePriceBean> getDimePriceDetail(@Validated GetDimePriceDetailParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RDimePriceBean> res = new ListResult<RDimePriceBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.getDimePriceDetail(param, request, response);
	}

	/**
	 * 获取影厅信息
	 **/
	@RequestMapping("/v1/getRoomById")
	@ResponseBody
	public ObjectResult<RRoomBean> getRoomById(@Validated DelByIdParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ObjectResult<RRoomBean> res = new ObjectResult<RRoomBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return roomController.getRoomById(param, request, response);
	}
}
